package lc.双指针;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/1
 */
public class 剑指OfferII018_有效的回文 {


    public boolean isPalindrome(String s) {
        int l = 0, r = s.length() - 1;
        char[] chars = s.toCharArray();
        while (l < r) {

            while (l < r && !Character.isLetter(s.charAt(l)) && !Character.isDigit(s.charAt(l))) {
                l++;
            }
            while (l < r && !Character.isLetter(s.charAt(r)) && !Character.isDigit(s.charAt(r))) {
                r--;
            }
            if(Character.toLowerCase(s.charAt(l)) != Character.toLowerCase(s.charAt(r))){
                return false;
            }
            l++;
            r--;
        }
        return true;

    }
}
